﻿using System;
using UnityEngine;

public static class ObjectExtension
{
    public static void ReportError(this object obj,string info)
    {
        Debug.LogError($"{obj}: " + info);
    }
 /*   public static object TypeDefaultValue(this Type type)
    {
        if (type == typeof(string))
        {
            return "";
        }
        return typeof(ObjectExtension).GetMethod("DefaultValue").MakeGenericMethod(type).Invoke(null,null);
    }
    public static T DefaultValue<T>()
    {
        return default(T);
    }
    public static bool EqualsDefault<T>(this object obj)
    {
        Debug.Assert(obj != null);
        if (obj == null) return true;
        else if (obj is ValueType)
        {
            return obj.Equals(default(T));
        }
        else if (obj is string)
        {
            return String.IsNullOrEmpty((string)obj);
        }
        else return false;
    }

    public static bool EqualsValue(this object obj,object value)
    {
        Debug.Assert(obj != null);
        if (obj is ValueType)
        {
            return obj.Equals(value);
        }
        else if (obj is string)
        {
            return obj.Equals(value);
        }
        else if (obj == null)
        {
            return value == null;
        }
        else return obj == value;
    }
    public static bool EqualsDefault(this object obj)
    {
        if (obj == null) return true;
        else if (obj is ValueType)
        {
            return obj.Equals(TypeDefaultValue(obj.GetType()));
        }else if(obj is string)
        {
            return String.IsNullOrEmpty((string)obj);
        }
        else return false;
    }*/
}
